package com.questetra.OAuth.apps.Twitter.parser
{
	public class TwitterStatus
	{
		public function TwitterStatus()
		{
		}
		
		public var created_at:Date;
		public var id:uint;
		public var text:String;
		public var source:String;
		public var truncated:Boolean;
		public var in_reply_to_status_id:uint;
		public var in_reply_to_user_id:uint;
		public var favorited:Boolean;
		public var in_reply_to_screen_name:String;
		public var user:TwitterUser;
		public var geo:TwitterGeo;
		
		public function set status_xml(status:XML):void{
			this.created_at = TwitterDateUtil.TwitterDateToDate(status.created_at);
			this.id = status.id;
			this.text = status.text;
			this.source =status.source;
			this.truncated = (status.truncated == "true");
			this.in_reply_to_status_id = status.in_reply_to_status_id;
			this.in_reply_to_user_id = status.in_reply_to_user_id;
			this.favorited = (status.favorited == "true");
			this.in_reply_to_screen_name = status.in_reply_to_screen_name;
			
			this.user = new TwitterUser();
			var u_list:XMLList = status.user;
			this.user.user_xml = u_list[0];
			
			this.geo = new TwitterGeo();
			var g_list:XMLList = status.geo;
			this.geo.geo_xml = g_list[0];
		}
		
		public function set status_json(json:Object):void{
			this.created_at = TwitterDateUtil.TwitterDateToDate(json.created_at);
			this.id = json.id;
			this.text = json.text;
			this.source =json.source;
			this.in_reply_to_user_id = json.to_user_id;
			/*
			this.truncated = (json.truncated == "true");
			this.in_reply_to_status_id = json.in_reply_to_status_id;
			this.in_reply_to_user_id = json.in_reply_to_user_id;
			this.favorited = (json.favorited == "true");
			this.in_reply_to_screen_name = json.in_reply_to_screen_name;
			*/
			this.user = new TwitterUser();
			this.user.name = json.from_user;
			
			this.geo = new TwitterGeo();
		}
		
		public function toString():String{
			return "{id:"+ this.id +", " + 
					"text:"+this.text+", " + 
					"source:"+this.source+" " + 
					"truncated:"+this.truncated+", " + 
					"in_reply_to_status_id:"+this.in_reply_to_status_id+", " + 
					"in_reply_to_user_id:"+this.in_reply_to_user_id+", " + 
					"favorited:"+this.favorited+", " + 
					"in_reply_to_screen_name:"+this.in_reply_to_screen_name+", " + 
					"user:"+this.user.toString()+", " + 
					"geo:"+this.geo.toString()+"}";
		}
	}
}